﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SchoolManage.aspx.cs" Inherits="Educational_BasicBackground_SchoolManage" %>
<script type="text/javascript">
window.addEvent('domready',function(){
    
    window.updateDataForSchool=function(schoolId,type){
        var jsonUrl;
        var checkTemp=true;
        if(type=='Review'||type=='Unlock')
        {
            jsonUrl='../../Educational/Ajax/SchoolManage.aspx?Action=updateStatus&schoolId='+schoolId.toString()+'&status=9';
        }
        if(type=='Lock')
        {
            jsonUrl='../../Educational/Ajax/SchoolManage.aspx?Action=updateStatus&schoolId='+schoolId.toString()+'&status=2';
        }
        if(type=='Delete')
        {
            jsonUrl='../../Educational/Ajax/SchoolManage.aspx?Action=updateStatus&schoolId='+schoolId.toString()+'&status=1';
            if(!confirm('你确定要删除学校？此操作不可挽回！'))
                checkTemp=false;
        }
        if(checkTemp)
        {
            MUI.showModalMessage('正在执行操作');
            new Request.JSON({url:jsonUrl,noCache:true,onSuccess:function(result){
                MUI.hideModalMessage();
                if(result.error)
                    MUI.appendStatusMessage({'text':result.msg});
                else
                {
                    MUI.appendStatusMessage({'text':result.msg});
                    window.datagridForSchool.loadData();
                }
            },onFailure:function(error){
                MUI.appendStatusMessage({'text':'AJAX提交表单的过程中发生未知错误。'});
                MUI.hideModalMessage();
            }}).get();
        }
    };
    
    window.loadDataForSchool=function(){
        window.datagridForSchool = new omniGrid('dataList', {
            columnModel: [
            {header: '校名',dataIndex: 'schoolName',dataType:'string',width:150,sortable:true},
            {header: '登录ID',dataIndex: 'loginId',dataType:'string',width:100,sortable:true},
            {header: '学校类型',dataIndex: 'schoolId',dataType:'string',width:100,labelFunction:function(rowdata, r, columnModel){
                return rowdata.schoolType.dictionaryValue;
            }},
            {header: '负责人姓名',dataIndex: 'legalRepresentative',dataType:'string',width:70},
            {header: '负责人电话',dataIndex: 'telnumber',dataType:'string',width:110},
            {header: '最后登录时间',dataIndex: 'lastLoginTime',dataType:'date',width:150,sortable:true},
            {header: '最后登录IP',dataIndex: 'lastLoginIp',dataType:'string',width:120},
            {header: '登录次数',dataIndex: 'loginTimes',dataType:'number',width:60,sortable:true},
            {header: '注册时间',dataIndex: 'regTime',dataType:'date',width:150,sortable:true},
            {header: '状态',dataIndex: 'schoolId',dataType:'string',width:100,labelFunction:function(rowdata, r, columnModel){
                if(rowdata.status==0)
                    return '<span style="color:#0000FF">等待审核</span>';
                if(rowdata.status==2)
                    return '<span style="color:#FF0000">锁定不允许登录</span>';
                if(rowdata.status==9)
                    return '正常';
            }},
            {header: '操作',dataIndex: 'schoolId',dataType:'number',width:70,labelFunction:function(rowdata, r, columnModel){
                var returnStr;
                if(rowdata.status==0)
                    returnStr='<a href="#" onclick="window.updateDataForSchool('+rowdata.schoolId.toString()+',\'Review\');">审核</a>';
                if(rowdata.status==2)
                    returnStr='<a href="#" onclick="window.updateDataForSchool('+rowdata.schoolId.toString()+',\'Unlock\');">解锁</a>';
                if(rowdata.status==9)
                    returnStr='<a href="#" onclick="window.updateDataForSchool('+rowdata.schoolId.toString()+',\'Lock\');">锁定</a>';
                returnStr+='&nbsp;<a href="#" onclick="window.updateDataForSchool('+rowdata.schoolId.toString()+',\'Delete\');">删除</a>';
                return returnStr;
            }}
            ],
            buttons:[],
            url:"../../Educational/Ajax/SchoolManage.aspx?Action=search",
            urlMethod:'post',
            urlPostForm:'searchFormForSchool',
            perPageOptions: [20,50,100,200,500,1000],
            perPage:20,
            height:$('workspace').getStyle('height').toInt()-17,
            serverSort:false,
            sortHeader:true,
            pagination:true
        });
    };

    window.binddingEventForSchool=function(){
        $('searchFormForSchool').getElement('.button').addEvent('click',function(){
            window.datagridForSchool.options.page=1;
            window.datagridForSchool.loadData();
        });
    };
    
    window.initializeForSchool=function(){
        window.loadDataForSchool();
        window.binddingEventForSchool();
    };
    
    window.initForSchool=function(){
        window.initializeForSchool();
    };
    
    window.initForSchool();
});
</script>
<div id="dataList"></div>
<!--隐藏的表单-->
<div id="formContainer" style="display:none;">
<!--搜索条件表单-->
<form id="searchFormForSchool">
    <span class="span">校名</span>
    <input class="input" style="width:70px;" type="text" name="schoolName" />
    <span class="span">登录ID</span>
    <input class="input" style="width:70px;" type="text" name="loginId" />
    <input class="button" type="button" value="查询" />
</form>
</div>